package tgc.edu.ljc.config;

import java.util.concurrent.TimeUnit;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@EnableWebMvc
public class AppConfig implements WebMvcConfigurer {
	@Value(value="${web.file-url}")
	private String url;
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/media/**").addResourceLocations("file:/"+url+"/");
		registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
		registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
		//WebMvcConfigurer.super.addResourceHandlers(registry);
	}

	@Override
	public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
		// 超时时间设置为60s
        configurer.setDefaultTimeout(TimeUnit.SECONDS.toMillis(60));
	}
	
}
